package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.Travel;
import cn.wolfcode.luowowo.article.domain.TravelContent;
import cn.wolfcode.luowowo.article.query.TravelQuery;
import cn.wolfcode.luowowo.article.service.ITravelService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 猫教授
 * @date 2019/7/16 21:21
 */
@RequestMapping("travel")
@Controller
public class TravelController {
    @Reference
    private ITravelService travelService;

    /**
     * 游记审核列表
     * @param model
     * @param qo
     * @return
     */
    @RequestMapping("list")
    public String getList(Model model, @ModelAttribute("qo") TravelQuery qo){
        qo.setIspublic(true);
        qo.setOrderBy("lastUpdateTime asc");
        model.addAttribute("pageInfo",travelService.getList(qo));
        return "travel/list";
    }
  /*  @RequestMapping("releaseList")
    public String releaseList(Model model, TravelQueryObject qo){

        qo.setState(2);
        qo.setOrderBy("releaseTime desc");
        model.addAttribute("result",travelService.getList(qo));
        return "travel/releaseList";
    }

   */
  @RequestMapping("updateState")
  @ResponseBody
  public AjaxResult updateState(Long id, Integer state){
      travelService.updateState(id,state);
      return new AjaxResult(true,"修改成功");

  }
    @RequestMapping("getContentById")
    @ResponseBody
    public AjaxResult getContentById(Long id) {
        TravelContent content = travelService.getContent(id);
        return new AjaxResult(true, "获取成功", content);
    }

}
